# GCC Code Coverage Report

src/SurfaceCleaningController.cpp

Line | Branch | Exec | Source
--- | --- | --- | ---
1 |  |  | #include "rvc/SurfaceCleaningController.hpp"
2 |  |  |
3 |  |  | namespace rvc {
4 |  |  |
5 |  | 38 | SurfaceCleaningController::SurfaceCleaningController(CleaningCommandSink& cleaningSink)
6 |  | 38 | : cleaningSink_(cleaningSink) {}
7 |  |  |
8 |  | 27 | void SurfaceCleaningController::SessionStateChanged(bool active) {
9 |  | 27 | sessionActive_ = active;
10 |  |  |
11 | 2/2 ✓ Branch 2 → 3 taken 22 times. ✓ Branch 2 → 4 taken 5 times. | 27 | if (active) {
12 |  | 22 | cleaningMode_ = CleaningMode::Active;
13 |  | 22 | powerLevel_ = PowerLevel::Normal;
14 |  | 22 | return;
15 |  |  | }
16 |  |  |
17 |  | 5 | cleaningMode_ = CleaningMode::Suspended;
18 |  | 5 | powerLevel_ = PowerLevel::Off;
19 |  | 5 | send(CleaningCommand::suspend);
20 |  |  | }
21 |  |  |
22 |  | 6 | void SurfaceCleaningController::DustSignalUpdated(DustSignal signal) {
23 |  | 6 | dustSignal_ = signal;
24 |  |  |
25 | 2/2 ✓ Branch 2 → 3 taken 1 time. ✓ Branch 2 → 5 taken 5 times. | 6 | if (!sessionActive_) {
26 |  | 1 | send(CleaningCommand::unchangedOrDeferredTBD);
27 |  | 1 | return;
28 |  |  | }
29 |  |  |
30 | 2/5 ✓ Branch 5 → 6 taken 2 times. ✗ Branch 5 → 9 not taken. ✓ Branch 5 → 11 taken 3 times. ✗ Branch 5 → 13 not taken. ✗ Branch 5 → 15 not taken. | 5 | switch (signal) {
31 |  | 2 | case DustSignal::aboveThreshold:
32 |  | 2 | cleaningMode_ = CleaningMode::Boosted;
33 |  | 2 | powerLevel_ = PowerLevel::Boost;
34 |  | 2 | send(CleaningCommand::boost);
35 |  | 2 | cleaningMode_ = CleaningMode::Active;
36 |  | 2 | powerLevel_ = PowerLevel::Normal;
37 |  | 2 | send(CleaningCommand::normal);
38 |  | 2 | break;
39 |  | ✗ | case DustSignal::normal:
40 |  | ✗ | cleaningMode_ = CleaningMode::Active;
41 |  | ✗ | powerLevel_ = PowerLevel::Normal;
42 |  | ✗ | send(CleaningCommand::normal);
43 |  | ✗ | break;
44 |  | 3 | case DustSignal::invalid:
45 |  | 3 | cleaningMode_ = CleaningMode::Active;
46 |  | 3 | powerLevel_ = PowerLevel::Normal;
47 |  | 3 | send(CleaningCommand::normal);
48 |  | 3 | break;
49 |  | ✗ | case DustSignal::TBD:
50 |  | ✗ | send(CleaningCommand::unchangedOrDeferredTBD);
51 |  | ✗ | break;
52 |  |  | }
53 |  |  | }
54 |  |  |
55 |  | 6 | void SurfaceCleaningController::SuspendCleaningForManeuver() {
56 |  | 6 | cleaningMode_ = CleaningMode::Suspended;
57 |  | 6 | send(CleaningCommand::suspend);
58 |  | 6 | }
59 |  |  |
60 |  | 6 | void SurfaceCleaningController::ResumeCleaningAfterManeuver() {
61 | 2/2 ✓ Branch 2 → 3 taken 1 time. ✓ Branch 2 → 5 taken 5 times. | 6 | if (!sessionActive_) {
62 |  | 1 | send(CleaningCommand::unchangedOrDeferredTBD);
63 |  | 1 | return;
64 |  |  | }
65 |  |  |
66 |  | 5 | cleaningMode_ = CleaningMode::Active;
67 |  | 5 | powerLevel_ = PowerLevel::Normal;
68 |  | 5 | send(CleaningCommand::active);
69 |  |  | }
70 |  |  |
71 |  | 25 | void SurfaceCleaningController::send(CleaningCommand command) {
72 |  | 25 | cleaningSink_.CleaningCommand(command);
73 |  | 25 | }
74 |  |  |
75 |  |  | } // namespace rvc
76 |  |  |